/**
 * @file:          MotorRippleCompensator.h
 * @brief:         
 * @details:       
 * @author:        wjh
 * @date created:  2023.08.03
 * @version:       1.0.0
 * @par copyright (c):
 *   
 * @par history (desc):
 *   version:1.0.0, wjh, 2023.08.03,18:13:28
 */


#ifndef _MOTORRIPPLECOMPENSATOR_H_
#define _MOTORRIPPLECOMPENSATOR_H_

/* Include Files **************************************************************/
#include "Datatype.h"

/* Macro Definition ***********************************************************/
#define NUM_OF_SIN_TERM 4

/* Data Type Define ***********************************************************/
typedef union SinCoeffs
{
    struct SinCoeffsTerms
    {
        float32 A;
        float32 n;
        float32 phi;
    }term;
    float32 all[sizeof(struct SinCoeffsTerms)/sizeof(float32)];
}SinCoeffs;

typedef struct MotorRippleCompensator
{
    /* public data */
    uint16 en;
    float32 param_gain;
    float32 param_limit;
    SinCoeffs sin_coeffs[NUM_OF_SIN_TERM];

    /* private data */
    
    /* public method */
    void (*Init)(struct MotorRippleCompensator *self);
    float32 (*Run)(struct MotorRippleCompensator *self, float32 theta);
    /* private method */
    
}MotorRippleCompensator;

/* Variable Declare ***********************************************************/

/* Function Declare ***********************************************************/
void MotorRippleCompensator_Init(struct MotorRippleCompensator *self);
float32 MotorRippleCompensator_Run(struct MotorRippleCompensator *self, float32 theta);

#endif